####################################################################################################
# @author       David Kirwan https://github.com/davidkirwan/ardtweeno
# @description  Ardtweeno Gem Rakefile
#
# @date         02-07-2013
####################################################################################################

begin
  require 'bundler'
  Bundler::GemHelper.install_tasks
rescue Exception => e
  raise 'bundler gem not found, please install bundler and try again.'
end


task :default => 'menu'

task :menu do
  puts welcomeMsg = <<-MSG
rake build    # Build ardtweeno-x.x.x.gem into the pkg directory
rake install  # Build and install ardtweeno-x.x.x.gem into system gems
rake test     # Run the unit testing suite on this gem.
MSG
end

desc "Run the unit testing suite on this gem."
task :test => :tty0tty do
  require "./test/test_helper.rb"
end

# Build the tty0tty binary before running tests
task :tty0tty => :clean_tty0tty do
  thePath = File.dirname(__FILE__) + "/test/debug/tty0tty-1.1/pts/"
  sh "gcc -Wall -O2 -D_GNU_SOURCE #{thePath}tty0tty.c -o #{thePath}tty0tty"
end

# Clean the build before compiling
task :clean_tty0tty do
  thePath = File.dirname(__FILE__) + "/test/debug/tty0tty-1.1/pts/"
  sh "rm -rf #{thePath}tty0tty #{thePath}*.o #{thePath}core"
end
